//
//  exchangeCell.m
//  SSSAllRollAgency
//
//  Created by Darker on 2017/3/13.
//  Copyright © 2017年 Darker. All rights reserved.
//

#import "exchangeCell.h"
#import "ExchangeRecordModel.h"

@interface exchangeCell()

{
    UILabel *_label2;
}

@end

@implementation exchangeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = [UIColor colorWithHex:@"F9F9FA"];;
        //初始化子视图
        [self initSubsView];
    }
    return self;
}
- (void)initSubsView{
    
    UIImageView *bgImageView = [[UIImageView alloc]init];
    bgImageView.image = [UIImage imageNamed:@"pic_bg"];
    //bgImageView.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0.5];
    bgImageView.layer.cornerRadius = 5;
    bgImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgImageView];
    bgImageView.sd_layout
    .topSpaceToView(self.contentView,HeigthIos6CompeteWithCurrent(5))
    .rightSpaceToView(self.contentView,WidthIos6CompeteWithCurrent(10))
    .leftSpaceToView(self.contentView,WidthIos6CompeteWithCurrent(10))
    .bottomSpaceToView(self.contentView,HeigthIos6CompeteWithCurrent(5));
    
    UIImageView *startImageView = [[UIImageView alloc]init];
    startImageView.image = [UIImage imageNamed:@"icon_heart"];
    //startImageView.backgroundColor = [UIColor redColor];
    [bgImageView addSubview:startImageView];
    startImageView.sd_layout
    .centerYEqualToView(bgImageView)
    .leftSpaceToView(bgImageView,WidthIos6CompeteWithCurrent(20))
    .widthIs(WidthIos6CompeteWithCurrent(20))
    .heightIs(HeigthIos6CompeteWithCurrent(20));
    
    UIView *centerView = [[UIView alloc]init];
    centerView.backgroundColor = [UIColor clearColor];
    [bgImageView addSubview:centerView];
    centerView.sd_layout
    .centerYEqualToView(bgImageView)
    .leftSpaceToView(startImageView,WidthIos6CompeteWithCurrent(0))
    .widthIs(WidthIos6CompeteWithCurrent(70))
    .heightIs(HeigthIos6CompeteWithCurrent(30));
    
    
    //兑换善心
    UILabel *exchangeStartLabel = [[UILabel alloc]init];
    exchangeStartLabel.textAlignment = NSTextAlignmentCenter;
    exchangeStartLabel.text = @"兑换善心";
    exchangeStartLabel.font = [SSSFont systemFontOfSize:15];
    exchangeStartLabel.textColor = [UIColor colorWithHex:@"6D6D6D"];
    [centerView addSubview:exchangeStartLabel];
    exchangeStartLabel.sd_layout
    .topSpaceToView(centerView,0)
    .leftSpaceToView(centerView,0)
    .rightSpaceToView(centerView,0)
    .heightIs(centerView.frame.size.height/2);
    
    _nuLabel = [[UILabel alloc]init];
    _nuLabel.textColor = [UIColor colorWithHex:@"6D6D6D"];
    _nuLabel.textAlignment = NSTextAlignmentCenter;
    _nuLabel.font = [SSSFont systemFontOfSize:15];
    _nuLabel.text = @"4000";
    [centerView addSubview:_nuLabel];
    _nuLabel.sd_layout
    .topSpaceToView(exchangeStartLabel,0)
    .rightSpaceToView(centerView,0)
    .bottomSpaceToView(centerView,0)
    .leftSpaceToView(centerView,0);
    
    UIView *centerView1 = [[UIView alloc]init];
    centerView1.backgroundColor = [UIColor clearColor];
    [bgImageView addSubview:centerView1];
    centerView1.sd_layout
    .centerYEqualToView(bgImageView)
    .centerXEqualToView(bgImageView)
    .widthIs(WidthIos6CompeteWithCurrent(100))
    .heightIs(HeigthIos6CompeteWithCurrent(30));

    
    //时间
    _timeLable = [[UILabel alloc]init];
    _timeLable.text = @"2017-01-02";
    _timeLable.textAlignment = NSTextAlignmentCenter;
    _timeLable.font = [SSSFont systemFontOfSize:15];
    _timeLable.textColor = [UIColor colorWithHex:@"BBBBBB"];
    [centerView1 addSubview:_timeLable];
    _timeLable.sd_layout
    .topSpaceToView(centerView1,0)
    .leftSpaceToView(centerView1,0)
    .rightSpaceToView(centerView1,0)
    .heightIs(centerView1.frame.size.height/2);
    
    _secLable = [[UILabel alloc]init];
    _secLable.textColor = [UIColor colorWithHex:@"BBBBBB"];
    _secLable.font = [SSSFont systemFontOfSize:15];
    _secLable.textAlignment = NSTextAlignmentCenter;
    _secLable.text = @"18:20:02";
    [centerView1 addSubview:_secLable];
    _secLable.sd_layout
    .topSpaceToView(exchangeStartLabel,0)
    .rightSpaceToView(centerView1,0)
    .bottomSpaceToView(centerView1,0)
    .leftSpaceToView(centerView1,0);
    
    //详情
    UIButton *detailBtn = [[UIButton alloc]init];
    detailBtn.titleLabel.font = [SSSFont systemFontOfSize:15];
    [detailBtn setTitle:@"详情" forState:UIControlStateNormal];
    [detailBtn setTitleColor:[UIColor colorWithHex:@"BBBBBB"] forState:UIControlStateNormal];
    [bgImageView addSubview:detailBtn];
    detailBtn.sd_layout
    .bottomSpaceToView(bgImageView,HeigthIos6CompeteWithCurrent(7))
    .rightSpaceToView(bgImageView,WidthIos6CompeteWithCurrent(27))
    .widthIs(WidthIos6CompeteWithCurrent(50))
    .heightIs(HeigthIos6CompeteWithCurrent(30));
    
    UIButton *detailRaowBtn = [[UIButton alloc]init];
    [detailRaowBtn setBackgroundImage:[UIImage imageNamed:@"icon_arrow_right"] forState:UIControlStateNormal];
    [bgImageView addSubview:detailRaowBtn];
    detailRaowBtn.sd_layout
    .leftSpaceToView(detailBtn,HeigthIos6CompeteWithCurrent(0))
    .centerYEqualToView(detailBtn)
    .widthIs(WidthIos6CompeteWithCurrent(6))
    .heightIs(HeigthIos6CompeteWithCurrent(11));
    
    
    _label2 = [[UILabel alloc]init];
    _label2.text = @"打款成功";
    _label2.textColor = [UIColor colorWithHex:@"839FA3"];
    _label2.font = [SSSFont systemFontOfSize:18];
    [bgImageView addSubview:_label2];
    _label2.sd_layout
    .leftSpaceToView(bgImageView,WidthIos6CompeteWithCurrent(253))
    .centerYEqualToView(bgImageView)
    .heightIs(HeigthIos6CompeteWithCurrent(16))
    .widthIs([ZDKitManager zd_AutoSizeOfWidthWithText:_label2.text font:_label2.font height:HeigthIos6CompeteWithCurrent(16)]);
    
    
    
//    //图像
//    UIImageView *imageView = [[UIImageView alloc]init];
//    imageView.image = [UIImage imageNamed:@""];
//    imageView.backgroundColor = [UIColor yellowColor];
//    [bgImageView addSubview:imageView];
//    imageView.sd_layout
//    .rightSpaceToView(bgImageView,WidthIos6CompeteWithCurrent(30))
//    .centerYEqualToView(bgImageView)
//    .heightIs(HeigthIos6CompeteWithCurrent(70))
//    .widthIs(WidthIos6CompeteWithCurrent(70));
//    imageView.layer.masksToBounds = YES;
//    imageView.layer.cornerRadius = imageView.frame.size.height/2;
    
    
    
}
- (void)setModel:(ExchangeRecordModel *)model{
    
    _model = model;
    if ([NSString stringWithFormat:@"%@",model.creatDate].length <= 0) {
        
        self.timeLable.text = @"";
        self.secLable.text = @"";
    }else{
        
        self.timeLable.text = [model.creatDate xhstringWithFormat:@"yyyy-MM-dd"];
        _secLable.text = [model.creatDate xhstringWithFormat:@"HH:mm:ss"];
    }
    if (model.state == 1) {
        
        _label2.text = @"打款成功";
        
    }else{
        
        _label2.text = @"待打款";
    }
    _nuLabel.text = [NSString stringWithFormat:@"%@",model.exchangeShandian];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
